import java.util.ArrayDeque;

/**
 * Created with Intellij IDEA
 * Description
 * User:ASUS
 * Date:2024-09-11
 * Time:20:19
 */
public class MyQueue {
    public ArrayDeque<Integer> stack1;
    public ArrayDeque<Integer> stack2;
    public MyQueue(){
        stack1=new ArrayDeque<>();
        stack2=new ArrayDeque<>();
    }
    public void push(int x){
        stack1.push(x);
    }
    public int pop(){
        if(empty()){
            return -1;
        }
        if(stack2.isEmpty()){
            //第一个栈里面所有的元素 放到第二个栈当中
            while(stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }
    public int peek(){
        if(empty()){
            return -1;
        }
        if(stack2.isEmpty()){
            //第一个栈里面所有的元素 放到第二个栈当中
            while(stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.peek();
    }
    public boolean empty(){
        return stack1.isEmpty()&&stack2.isEmpty();
    }
}
